package com.bangdream.michelia.view.adapter.viewpage;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bangdream.michelia.R;
import com.bangdream.michelia.entity.RecommendBean;
import com.bangdream.michelia.tool.LoopVPAdapter;
import com.bangdream.michelia.utils.ImageLoadUtils;

import java.util.ArrayList;

/**
 * @date on 2018/6/19 22:11
 * @email 909732184@qq.com
 * 首页头部广告的适配器
 */
public class AdViewPageAdapter extends LoopVPAdapter<RecommendBean> {
    private ViewGroup.LayoutParams layoutParams;
    public AdViewPageAdapter(Context context, ArrayList<RecommendBean> datas, ViewPager viewPager) {
        super(context, datas, viewPager);
    }

    @Override
    protected View getItemView(RecommendBean data) {
        if (layoutParams == null) {
            layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        }
//            HomeAdFragment homeAdFragment = new HomeAdFragment();
//            Bundle bundle = new Bundle();
//            bundle.putString("data",data);
//            homeAdFragment.setArguments(bundle);

        ImageView imageView = new ImageView(mContext);
        imageView.setLayoutParams(layoutParams);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        ImageLoadUtils.ImageLoad(mContext,data.getCover(),imageView,R.mipmap.icon_temp_curriculum2);

        return imageView;
    }
}